import java.util.Scanner;

public class recursion {


    //写一个递归方法，输入一个非负整数，返回组成它的数字之和. 例如，输入 1729, 则应该返回 1+7+2+9，它的和是19
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        System.out.println(sep(k));
    }
    public static int sep(int w){
        if(w<9){
            return w;
        }else
            return w%10+sep(w/10);


//        if(w<9){
//            System.out.println(w);;
//        }else
//           sep(w/10);

    }


    //递归求 1 + 2 + 3 + ... + 10
    public static void main3(String[] args) {
        System.out.println(sum(10));
    }
    public static int sum(int x){
        if(x==1){
            return 1;
        }else
            return x+sum(x-1);
    }



    //按顺序打印一个数字的每一位(例如 1234 打印出 1 2 3 4)
    public static void main2(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        dev(n);
    }
    public static void dev(int num){
        if (num > 10) {
            dev(num/10);
        }
        System.out.println(num%10);
    }




    // 递归求 N 的阶乘
    public static void main1(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        System.out.println(set(n));
    }

    public static int set(int n) {
        if (n == 1) {
            return 1;
        }else
            return (n*set(n-1));
    }


}
